package com.rcadmin.busi.example.dao;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.rcadmin.busi.example.ddl.User;
import com.rcadmin.core.jpa.BaseDao;
import com.rcadmin.core.jpa.util.PageBean;

/**
 * 
 * @author tanson lam
 * @create 2016年9月5日
 */
@Component
public class UserDao {

	@Autowired
	private BaseDao baseDao;

	public void save(User user) {
		baseDao.save(user);
	}

	public void update(User user) {
		baseDao.update(user);
	}

	public void delete(User user) {
		baseDao.delete(user);
	}

	public List<User> findByName(String name) {
		List<User> list = baseDao.find("name='" + name + "'", User.class);
		return list;
	}

	public User findOne(Integer id) {
		return baseDao.findOne(id, User.class);
	}

	public PageBean<User> pageQuery(String condition, String orderBy,
			Integer pageSize, Integer page) {
		return baseDao
				.pageQuery(condition, orderBy, pageSize, page, User.class);
	}
}
